package com.ruoyi.web.controller.cashier;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.SySelfBookingRefundOrder;
import com.ruoyi.system.domain.SySelfServiceBookingOrder;
import com.ruoyi.system.dto.SelfServiceOrderQueryDTO;
import com.ruoyi.system.service.SySelfBookingRefundOrderService;
import com.ruoyi.system.util.BaseResponse;
import com.ruoyi.system.util.StoreIdUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/refund-order")
@Api(tags = "预定-自助预订-退款订单管理")
public class SySelfBookingRefundOrderController extends BaseController {

    @Autowired
    private SySelfBookingRefundOrderService sySelfBookingRefundOrderService;

    @Autowired
    private StoreIdUtils storeIdUtils;

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取退款订单详情")
    public SySelfBookingRefundOrder getById(@PathVariable Long id) {
        return sySelfBookingRefundOrderService.getById(id);
    }

    @PostMapping
    @ApiOperation("新增退款订单")
    public boolean create(@RequestBody SySelfBookingRefundOrder order) {
        order.setStoreId(storeIdUtils.getStoreId());
        return sySelfBookingRefundOrderService.save(order);
    }

    @PutMapping
    @ApiOperation("更新退款订单")
    public boolean update(@RequestBody SySelfBookingRefundOrder order) {
        return sySelfBookingRefundOrderService.updateById(order);
    }

    @PostMapping("/page")
    @ApiOperation("获取所有退款订单列表")
    public BaseResponse<IPage<SySelfBookingRefundOrder>> getAll(@RequestBody SelfServiceOrderQueryDTO orderDTO) {
        IPage<SySelfBookingRefundOrder> list = sySelfBookingRefundOrderService.getList(orderDTO);
        return BaseResponse.success(list);
    }
}
